import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useAppStore = defineStore('app', () => {
  // 应用状态
  const isLoading = ref(false)
  const systemInfo = ref({
    version: '1.0.0',
    name: 'AI智能文档处理系统',
    description: '智能分析Word文档，自动识别设备类型，验证命名规范'
  })

  // 统计信息
  const statistics = ref({
    totalDocuments: 0,
    processedDocuments: 0,
    totalDevices: 0,
    validDevices: 0,
    systemUptime: '0小时'
  })

  // 设置加载状态
  const setLoading = (loading: boolean) => {
    isLoading.value = loading
  }

  // 更新统计信息
  const updateStatistics = (stats: Partial<typeof statistics.value>) => {
    statistics.value = { ...statistics.value, ...stats }
  }

  // 重置状态
  const resetState = () => {
    isLoading.value = false
    statistics.value = {
      totalDocuments: 0,
      processedDocuments: 0,
      totalDevices: 0,
      validDevices: 0,
      systemUptime: '0小时'
    }
  }

  return {
    isLoading,
    systemInfo,
    statistics,
    setLoading,
    updateStatistics,
    resetState
  }
})
